package com.zjf.carpark.service.impl;

import com.zjf.carpark.dao.AccessInfoMapper;
import com.zjf.carpark.entities.AccessIncome;
import com.zjf.carpark.entities.AccessInfo;
import com.zjf.carpark.entities.AccessNum;
import com.zjf.carpark.service.AccessInfoService;
import com.zjf.carpark.utils.ResponseData;
import com.zjf.carpark.vo.AccessByCarNumVo;
import com.zjf.carpark.vo.AccessInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.zjf.carpark.utils.CodeAndMessage.CODE200;
import static com.zjf.carpark.utils.CodeAndMessage.SUCCESS;

/**
 * @description:
 * @author: 张建飞
 * @createDate: 2019/12/21
 * @version: 1.0
 */
@Service
public class AccessInfoServiceImpl extends BaseServiceImpl<AccessInfo> implements AccessInfoService {
    @Autowired
    private AccessInfoMapper accessInfoMapper;


    @Override
    public int out(AccessInfo accessInfo) {
        return accessInfoMapper.out(accessInfo);
    }

    @Override
    public AccessInfo selectByCarNum(String carNum) {
        return accessInfoMapper.selectByCarNum(carNum);
    }

    @Override
    public List<AccessInfo> selectAllLinShi(AccessInfoVO accessInfoVo) {
        if ("".equals(accessInfoVo.getCarNum())) {
            accessInfoVo.setCarNum(null);
        }
        return accessInfoMapper.selectAllLinShi(accessInfoVo);
    }

    @Override
    public int totalCount(AccessInfoVO accessInfoVo) {
        return accessInfoMapper.totalCount(accessInfoVo);
    }

    @Override
    public List<AccessInfo> selectAllFixed(AccessInfoVO accessInfoVo) {
        return accessInfoMapper.selectAllFixed(accessInfoVo);
    }

    @Override
    public int fixedTotalCount(AccessInfoVO accessInfoVo) {
        return accessInfoMapper.fixedTotalCount(accessInfoVo);
    }

    @Override
    public int selectCount(Integer begin, Integer end) {
        return accessInfoMapper.selectCount(begin, end);
    }

    @Override
    public List<AccessInfo> selectAllByCarNum(AccessByCarNumVo accessByCarNumVo) {
        return accessInfoMapper.selectAllByCarNum(accessByCarNumVo);
    }

    @Override
    public AccessInfo selectByAccessId(String accessId) {
        return accessInfoMapper.selectByAccessId(accessId);
    }

    @Override
    public int selectCountByCarNum(AccessByCarNumVo accessByCarNumVo) {
        return accessInfoMapper.selectCountByCarNum(accessByCarNumVo);
    }

    @Override
    public List<AccessNum> selectCountByYear(int year) {
        return accessInfoMapper.selectCountByYear(year);
    }

    @Override
    public List<AccessIncome> selectIncomeByYear(int year) {
        return accessInfoMapper.selectIncomeByYear(year);
    }

    @Override
    public ResponseData getData() {
        ResponseData responseData = new ResponseData(CODE200, SUCCESS);
        responseData.putDataValue("linshi", accessInfoMapper.linShiCount());
        responseData.putDataValue("fixed", accessInfoMapper.fixedCount());
        return responseData;
    }

}
